import { S } from '../../s';
import { IPSApplication } from '../ipsapplication';
import { IPSAppCounterRef } from '../control/ipsapp-counter-ref';
import { IPSAppDERS } from '../dataentity/ipsapp-ders';
import { IPSAppDataEntity } from '../dataentity/ipsapp-data-entity';
import { IPSAppDEView } from './ipsapp-deview';
import { IPSAppDEWFActionView } from './ipsapp-dewfaction-view';
import { IPSAppDEWFView } from './ipsapp-dewfview';
import { PSAppViewImpl } from './psapp-view-impl';
import { IPSAppWF } from '../wf/ipsapp-wf';
import { IPSAppWFVer } from '../wf/ipsapp-wfver';
import { IPSLanguageRes } from '../../res/ipslanguage-res';

export class PSAppDEViewImpl
  extends PSAppViewImpl
  implements IPSAppDEView, IPSAppDEWFView, IPSAppDEWFActionView
{
  /**
   * 获取应用实体视图的关系集合
   */
  protected psappderspaths: IPSAppDERS[][];
  getPSAppDERSPaths(): IPSAppDERS[][] | null {
    if (this.psappderspaths != null) {
      return this.psappderspaths;
    }
    const value = this.M.getPSAppDERSPaths;
    if (value == null) {
      return null;
    }
    const arr: any[] = [];
    for (let i = 0; i < value.length; i++) {
      const psAppDERSs = value[i];
      if (psAppDERSs) {
        const subArr: any[] = [];
        for (let j = 0; j < psAppDERSs.length; j++) {
          subArr.push(
            this.getPSModel4(
              'app.dataentity.IPSAppDERS',
              psAppDERSs[j],
              'getPSAppDERSPaths',
            ) as IPSAppDERS,
          );
        }
        arr.push(subArr);
      }
    }
    this.psappderspaths = arr;
    return this.psappderspaths;
  }

  get accUserMode(): 0 | 2 | 3 | 4 {
    return this.M.accUserMode;
  }

  protected cappslanguageres: IPSLanguageRes;
  getCapPSLanguageRes(): IPSLanguageRes | null {
    return (
      this.cappslanguageres ||
      (this.cappslanguageres = this.fillObjectModel(
        S._276,
        this.M.getCapPSLanguageRes,
        S._2a8,
      ) as IPSLanguageRes)
    );
  }

  get caption(): string {
    return this.M.caption;
  }

  get funcViewMode():
    | 'PICKUPVIEW'
    | 'EDITVIEW'
    | 'MAINVIEW'
    | 'INDEXDEPICKUPVIEW'
    | 'FORMPICKUPVIEW'
    | 'MPICKUPVIEW'
    | 'MDATAVIEW'
    | 'WFEDITVIEW'
    | 'WFMDATAVIEW'
    | 'WFSTARTVIEW'
    | 'WFACTIONVIEW'
    | 'WFUTILACTIONVIEW'
    | 'REDIRECTVIEW'
    | 'MOBPICKUPVIEW'
    | 'MOBEDITVIEW'
    | 'MOBMAINVIEW'
    | 'MOBINDEXDEPICKUPVIEW'
    | 'MOBFORMPICKUPVIEW'
    | 'MOBMPICKUPVIEW'
    | 'MOBMDATAVIEW'
    | 'MOBWFEDITVIEW'
    | 'MOBWFMDATAVIEW'
    | 'MOBWFSTARTVIEW'
    | 'MOBWFACTIONVIEW'
    | 'MOBWFUTILACTIONVIEW'
    | 'MOBREDIRECTVIEW' {
    return this.M.funcViewMode;
  }

  get funcViewParam(): string {
    return this.M.funcViewParam;
  }

  get height(): number {
    return this.M.height != null ? this.M.height : 0;
  }

  get openMode():
    | 'INDEXVIEWTAB'
    | 'POPUP'
    | 'POPUPMODAL'
    | 'POPUPAPP'
    | 'DRAWER_LEFT'
    | 'DRAWER_RIGHT'
    | 'DRAWER_TOP'
    | 'DRAWER_BOTTOM'
    | 'POPOVER'
    | 'USER'
    | 'USER2'
    | 'USER3'
    | 'USER4' {
    return this.M.openMode;
  }

  protected psappcounterref: IPSAppCounterRef;
  getPSAppCounterRef(): IPSAppCounterRef | null {
    if (this.psappcounterref != null) return this.psappcounterref;
    const value = this.M.getPSAppCounterRef;
    if (value == null) {
      return;
    }
    this.psappcounterref = this.findPSAppCounterRef(value);
    return this.psappcounterref;
  }

  protected psappwf: IPSAppWF;
  getPSAppWF(): IPSAppWF | null {
    if (this.psappwf != null) return this.psappwf;
    const value = this.M.getPSAppWF;
    if (value == null) {
      return;
    }
    const ipsapplication = this.getParentPSModelObject(
      S._26e,
    ) as IPSApplication;
    if (ipsapplication != null) {
      this.psappwf = ipsapplication.findPSAppWF(value);
    }
    return this.psappwf;
  }

  protected psappwfver: IPSAppWFVer;
  getPSAppWFVer(): IPSAppWFVer | null {
    if (this.psappwfver != null) return this.psappwfver;
    const value = this.M.getPSAppWFVer;
    if (value == null) {
      return;
    }
    this.psappwfver = this.getPSAppWF().findPSAppWFVer(value);
    return this.psappwfver;
  }

  getPSDEViewCodeName(): string {
    return this.M.getPSDEViewCodeName;
  }

  getPSDEViewId(): string {
    return this.M.getPSDEViewId;
  }

  protected parentpsappdataentity: IPSAppDataEntity;
  getParentPSAppDataEntity(): IPSAppDataEntity | null {
    return (
      this.parentpsappdataentity ||
      (this.parentpsappdataentity = this.fillObjectModel(
        S._f,
        this.M.getParentPSAppDataEntity,
        S._2ae,
      ) as IPSAppDataEntity)
    );
  }

  protected subcappslanguageres: IPSLanguageRes;
  getSubCapPSLanguageRes(): IPSLanguageRes | null {
    return (
      this.subcappslanguageres ||
      (this.subcappslanguageres = this.fillObjectModel(
        S._276,
        this.M.getSubCapPSLanguageRes,
        S._2b0,
      ) as IPSLanguageRes)
    );
  }

  get subCaption(): string {
    return this.M.subCaption;
  }

  get tempMode(): 0 | 1 | 2 {
    return this.M.tempMode != null ? this.M.tempMode : 0;
  }

  get title(): string {
    return this.M.title;
  }

  protected titlepslanguageres: IPSLanguageRes;
  getTitlePSLanguageRes(): IPSLanguageRes | null {
    return (
      this.titlepslanguageres ||
      (this.titlepslanguageres = this.fillObjectModel(
        S._276,
        this.M.getTitlePSLanguageRes,
        S._2b1,
      ) as IPSLanguageRes)
    );
  }

  get wFStepValue(): string {
    return this.M.wFStepValue;
  }

  get wFUtilType():
    | 'SENDBACK'
    | 'SUPPLYINFO'
    | 'ADDSTEPBEFORE'
    | 'ADDSTEPAFTER'
    | 'TAKEADVICE'
    | 'SENDCOPY'
    | 'REASSIGN'
    | 'USERACTION'
    | 'USERACTION2'
    | 'USERACTION3'
    | 'USERACTION4'
    | 'USERACTION5'
    | 'USERACTION6' {
    return this.M.wFUtilType;
  }

  get width(): number {
    return this.M.width != null ? this.M.width : 0;
  }

  get enableDP(): boolean {
    return this.M.enableDP;
  }

  get enableWF(): boolean {
    return this.M.enableWF != null ? this.M.enableWF : false;
  }

  get showCaptionBar(): boolean {
    return this.M.showCaptionBar != null ? this.M.showCaptionBar : true;
  }

  get wFIAMode(): boolean {
    return this.M.wFIAMode;
  }
  get cls(): string {
    return 'PSAppDEViewImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._20 || cls == S._21 || cls == S._22) return true;
    return super.instanceof(cls);
  }
}
